package nl.cwi.arne.lts.resource;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import nl.cwi.arne.lts.LTS;
import nl.cwi.arne.lts.Transition;

public class LTSPrinter {
	
	public void print(LTS lts, OutputStream out) throws IOException {
		
		OutputStreamWriter writer = new OutputStreamWriter(out);
		
		int initial = lts.getStates().indexOf(lts.getInitialState());
		writer.write("des (" + initial + "," + lts.getTransitions().size() + "," + lts.getStates().size() + ")\n");
		for (Transition transition : lts.getTransitions()) {
			writer.write("(" + lts.getStates().indexOf(transition.getSource()) + ",");
			writer.write("\"" + transition.getLabel() + "\",");
			writer.write(lts.getStates().indexOf(transition.getTarget()) + ")\n");			
		}
		
		writer.close();
		
	}

}
